package com.ego.user.service.impl;

import com.ego.auth.entity.UserInfo;
import com.ego.exception.EgoException;
import com.ego.exception.ExceptionEnum;
import com.ego.user.interceptor.LoginInterceptor;
import com.ego.user.mapper.UserAndInfoMapper;
import com.ego.user.pojo.UserAndInfo;
import com.ego.user.service.UserAndInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Slf4j
public class UserAndInfoServiceImpl implements UserAndInfoService {
    @Resource
    private UserAndInfoMapper userAndInfoMapper;


    @Transactional(readOnly = true)
    @Override
    public UserAndInfo getUserInfo() {
        //获取用户信息
        UserInfo userInfo = LoginInterceptor.getCurrUser();
        return userAndInfoMapper.selectById(userInfo.getId());
    }

    @Override
    @Transactional
    public int update(UserAndInfo userAndInfo) {
        return userAndInfoMapper.updateById(userAndInfo);
    }
}
